const sleep = ms => new Promise((resolve) => setTimeout(resolve, ms));
function fun(n){
    sleep(10*n).then(()=>{
        self.postMessage(`${n}\n`)
    })
} 
addEventListener('message', e => fun(parseInt(e.data)), false);